package service;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * 统一的接口增强
 * @author zhu_shuai
 * @since 8/4
 */
public class ServiceInvocation implements InvocationHandler {

    private Object target;

    public ServiceInvocation(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("方法执行前操作");
        // 反射获取方法
        Object invoke = method.invoke(target, args);
        System.out.println("方法执行后操作");
        return invoke;
    }
}
